package com.yyfax.pay.quartz.adapter.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yyfax.pay.common.annotation.DepositQueryTaskType;
import com.yyfax.pay.common.enums.FuiouBusiTypeEnum;
import com.yyfax.pay.depository.dao.FuiouUserRegisterDao;
import com.yyfax.pay.depository.domain.FuiouQueryTask;
import com.yyfax.pay.depository.domain.FuiouUserRegister;
import com.yyfax.pay.depository.service.inner.FuiouQueryService;
import com.yyfax.pay.depository.service.inner.impl.FuiouDepositRegisterServiceImpl;
import com.yyfax.pay.depository.vo.UserRegisterVO;
import com.yyfax.pay.quartz.adapter.DepositQueryHandlerAdapter;
import com.yyfax.pay.quartz.model.vo.TaskResultVO;

/**
 * 普通用户开户超时查询，订单更新
 *
 * @author liangqm
 * @date 2018-01-12 11:29:18
 * @since v2.0.7
 */
@Service
@DepositQueryTaskType(FuiouBusiTypeEnum.REGISTER)
public class FuiouUserRegisterQueryHandler implements DepositQueryHandlerAdapter {

	@Resource
	private FuiouQueryService queryService;

	@Resource
	private FuiouUserRegisterDao userRegisterDao;

	@Resource
	private FuiouDepositRegisterServiceImpl registerService;

	@Override
	public TaskResultVO handle(FuiouQueryTask task) throws Throwable {

		// 查询 开户订单
		FuiouUserRegister order = userRegisterDao.selectByPrimaryKey(task.getBusiId());

		UserRegisterVO vo = queryService.queryUserInfo2(order);
		if (!vo.isQuery()) {
			return new TaskResultVO(true);
		}

		return new TaskResultVO(false);
	}
}
